package com.ywk.nacosServer.business.controller;

import com.ywk.nacosServer.business.entity.Student;
import com.ywk.nacosServer.business.service.StudentService;
import com.ywk.nacosServer.conf.Conf;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author zbh
 * @Date 2023/6/28
 */
@RestController
@RequestMapping("/student")
@RefreshScope//nacos配置热更新（局部）
public class StudentController {

    @Autowired
    StudentService service;

    @Autowired//nacos配置热更新（全部）
    Conf conf;

    @Value("${conf.name}")//nacos配置热更新（局部）
    String ConfName;

    @GetMapping("/getCount")
    public void getCount(){
        System.out.println(service.getCount());
    }

    @GetMapping("/findAll")
    public List<Student> findAll(){
        return service.findAll();
    }

    @GetMapping("/getConf")
    public void getConf(){
        System.out.println("nacos配置热更新（全部）conf："+conf);
        System.out.println("nacos配置热更新（局部）ConfName："+ConfName);
    }
}
